## This program selects 250 random observations in a dataset.
## Assumes the FILENAME of the input data and WORKING DIRECTORY are established
## Vito D'Orazio, August 29, 2011
rm(list=ls())
library(Rlab)

set.seed(4426)

mydata <- read.delim(file="summary.sorted.2010", header=FALSE)

success <- 250 / nrow(mydata)

keep <- rbern(n=nrow(mydata),p=success)
mydata <- cbind(mydata,keep)

outdata <- mydata[which(mydata$keep==1),]
write.table(outdata,"summary.random250", quote=FALSE, sep="\t", col.names=FALSE, row.names=FALSE)
